package com.haixiaoke.saas.order.service.impl;

import com.haixiaoke.saas.common.utils.DateUtils;
import com.haixiaoke.saas.order.domain.OrderStateRecord;
import com.haixiaoke.saas.order.mapper.OrderStateRecordMapper;
import com.haixiaoke.saas.order.service.IOrderStateRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单状态变更记录Service业务层处理
 *
 * @author qixi
 * @date 2024-04-07
 */
@Service
public class OrderStateRecordServiceImpl implements IOrderStateRecordService {
    @Autowired
    private OrderStateRecordMapper orderStateRecordMapper;

    /**
     * 查询订单状态变更记录
     *
     * @param recordId 订单状态变更记录主键
     * @return 订单状态变更记录
     */
    @Override
    public OrderStateRecord selectOrderStateRecordByRecordId(Long recordId) {
        return orderStateRecordMapper.selectOrderStateRecordByRecordId(recordId);
    }

    /**
     * 查询订单状态变更记录列表
     *
     * @param orderStateRecord 订单状态变更记录
     * @return 订单状态变更记录
     */
    @Override
    public List<OrderStateRecord> selectOrderStateRecordList(OrderStateRecord orderStateRecord) {
        return orderStateRecordMapper.selectOrderStateRecordList(orderStateRecord);
    }

    /**
     * 新增订单状态变更记录
     *
     * @param orderStateRecord 订单状态变更记录
     * @return 结果
     */
    @Override
    public int insertOrderStateRecord(OrderStateRecord orderStateRecord) {
        orderStateRecord.setCreateTime(DateUtils.getNowDate());
        return orderStateRecordMapper.insertOrderStateRecord(orderStateRecord);
    }

    /**
     * 修改订单状态变更记录
     *
     * @param orderStateRecord 订单状态变更记录
     * @return 结果
     */
    @Override
    public int updateOrderStateRecord(OrderStateRecord orderStateRecord) {
        return orderStateRecordMapper.updateOrderStateRecord(orderStateRecord);
    }

    /**
     * 批量删除订单状态变更记录
     *
     * @param recordIds 需要删除的订单状态变更记录主键
     * @return 结果
     */
    @Override
    public int deleteOrderStateRecordByRecordIds(Long[] recordIds) {
        return orderStateRecordMapper.deleteOrderStateRecordByRecordIds(recordIds);
    }

    /**
     * 删除订单状态变更记录信息
     *
     * @param recordId 订单状态变更记录主键
     * @return 结果
     */
    @Override
    public int deleteOrderStateRecordByRecordId(Long recordId) {
        return orderStateRecordMapper.deleteOrderStateRecordByRecordId(recordId);
    }

    @Override
    public OrderStateRecord selectOrderStateRecordByOrderIdAndState(String orderId, String orderState) {
        return orderStateRecordMapper.selectOrderStateRecordByOrderIdAndState(orderId,orderState);
    }
}
